package com.mg.framework.kernel;

import android.graphics.Canvas;
import android.view.MotionEvent;

public abstract class ControllerScreen extends Screen implements Touchable {

	private int controllerWidth = -1;
	private int controllerHeight = -1;

	public ControllerScreen(int width, int height) {
		super(width, height);
		this.controllerWidth = this.controllerHeight = Math.min(this.width / 3,
				this.height / 3);
		this.addActor("moveController", new MoveController(this,
				this.controllerWidth, this.controllerHeight));
		this.addActor("okCommandController", new OKCommandController(this,
				this.controllerWidth, this.controllerHeight));
		this.addActor("cancelCommandController", new CancelCommandController(
				this, this.controllerWidth, this.controllerHeight));
	}

	@Override
	public void onTouchEvent(MotionEvent event) {
		String[] actorsName = { "moveController", "okCommandController",
				"cancelCommandController" };
		this.dispenseToActors(actorsName, event);
	}

	@Override
	public boolean isTouched(MotionEvent event) {
		return true;
	}

	@Override
	protected void screenUpdate(Canvas canvas) {
		this.getActor("moveController").screenUpdate(canvas);
		this.getActor("okCommandController").screenUpdate(canvas);
		this.getActor("cancelCommandController").screenUpdate(canvas);
	}

	@Override
	protected void gameUpdate() {
		this.getActor("moveController").gameUpdate();
		this.getActor("okCommandController").gameUpdate();
		this.getActor("cancelCommandController").gameUpdate();
	}

	protected void handleMove(float xOffset, float yOffset) {

	}

	protected void handleOK() {

	}

	protected void handleCancel() {

	}

	protected void handleReset() {

	}
}
